import { Drawer } from "antd";
import { DynamicComponent } from "@/components/dynamic-component";
import { ReactNode } from "react";

interface ModalDrawerProps {
	open: boolean;
	onClose: () => void;
	title: string;
	componentPath?: string;
	children?: ReactNode;
}

export const ModalDrawer = ({
	open,
	onClose,
	title,
	componentPath,
	children,
}: ModalDrawerProps) => {
	return (
		<Drawer
			title={title}
			placement="right"
			onClose={onClose}
			open={open}
			width={800}
			styles={{
				body: { padding: 0 },
			}}
		>
			{componentPath ? (
				<DynamicComponent path={componentPath} />
			) : (
				children
			)}
		</Drawer>
	);
};
